<html layout:decorate="~{diagnostic/diagnostic_layout}" xmlns:layout="http://www.w3.org/1999/xhtml">
<body>
    <div layout:fragment="content_diagnostic">
        <div class="main-body">
            <div style="float: right;margin-right: 10px;margin-bottom: 5px;">
                <a type="button" class="btn btn-primary btn-sm" style="margin-right: 10px;margin-bottom: 5px;" data-toggle="modal" href="javascript:void(0)" data-target="#modal">新增</a>
                <a type="button" class="btn btn-info btn-sm" style="margin-right: 10px;margin-bottom: 5px;" data-toggle="modal" href="javascript:void(0)" data-target="#modal">编辑</a>
                <a type="button" class="btn btn-danger btn-sm" style="margin-right: 10px;margin-bottom: 5px;" onclick="deleteDate()">删除</a>
                <a type="button" class="btn btn-primary btn-sm" style="margin-right: 10px;margin-bottom: 5px;" data-toggle="modal" href="/diagnostic/algorithm_add" data-target="#modal">修改触发条件</a>
            </div>
            <table id="dataTable" data-url="/diagnostic/algorithm_data" data-page-list=[]  data-striped="true" data-pagination="true" data-page-size="15" data-cache="false">

            </table>
        </div>

        <style>


        </style>

        <script>
            //table字段
            var dataFormat = [{
                title: '序号',
                align: 'center',
                formatter : function (value, row, index) {
                    return index + 1;
                }
            },{
                field: 'algorithmName',
                title: '算法名称',
                align: 'center'
            },{
                field: 'diagnosticEquipment',
                title: '对象',
                align: 'center'
            },{
                field: 'version',
                title: '版本',
                align: 'center'
            },{
                field: 'deployTime',
                align: 'center',
                title: '部署时间',
                formatter : function(value, row, index){
                    return formatTimeStrap(value);
                }
            },{
                field: 'remark',
                align: 'center',
                title: '备注'
            },{
                field: 'condition',
                align: 'center',
                title: '触发条件'
            },{
                field: 'reverseControl',
                align: 'center',
                title: '反向控制',
                formatter : formatControl
            },{
                field: 'process',
                align: 'center',
                title: '控制工序'
            },{
                field: 'childAlgorithm',
                align: 'center',
                title: '子算法'
            },{
                field: 'status',
                align: 'center',
                title: '有效',
                formatter : formatStatus
            }];

            //状态格式化
            function formatStatus(value, row, index) {
                var html = '';
                if (value == 1) {
                    html += '<input type="checkbox"/>';
                }

                if (value == 2) {
                    html += '<input type="checkbox" checked="checked"/>';
                }

                return [html].join('');
            }

            //控制反转格式化
            function formatControl(value, row, index) {
                var html = '';
                if (value == 2) {
                    html += '<p>是</p>';
                }
                return [html].join('');
            }

            //初始化table
            window.onload = function () {
                getTable(dataFormat, "dataTable");
            };

            function deleteDate() {
                alert("删除");
            }

        </script>
    </div>
</body>
</html>